package com.xbongbong.paas.help.subform;

import com.xbongbong.paas.domain.entity.PaasFormDataEntity;
import com.xbongbong.paas.enums.IndexTypeEnum;
import com.xbongbong.paas.factory.subform.SubFormFactory;
import com.xbongbong.paas.help.subform.abstracts.AbstractUserAndDepTeamTransferSubForm;
import com.xbongbong.paas.help.subform.abstracts.AbstractUserTeamTransferSubForm;
import com.xbongbong.saas.domain.entity.ContractPerformanceEntity;
import com.xbongbong.saas.domain.entity.ContractProductEntity;
import com.xbongbong.saas.domain.entity.DistributorAccountEntity;
import com.xbongbong.saas.domain.entity.ProductStockEntity;
import com.xbongbong.saas.domain.entity.ProductWarehouseEntity;
import com.xbongbong.saas.domain.entity.UserAndDepTeamEntity;
import com.xbongbong.saas.domain.entity.UserTeamEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 子表单数据库和es格式转化用heler
 * @author 魏荣杰
 * @date 2020/8/20 16:14
 */
@Component
public class TransferSubFormHelper {
    private static final Logger LOG = LoggerFactory.getLogger(TransferSubFormHelper.class);

    @Resource
    private SubFormFactory subFormFactory;

    /**
     * Description: 把数据库团队数据转化为es的格式
     * @param indexTypeEnum es索引枚举
     * @see com.xbongbong.paas.enums.IndexTypeEnum
     * @param userTeamEntity 团队实体
     * @return com.xbongbong.paas.domain.entity.PaasFormDataEntity
     * @author 魏荣杰
     * @date 2020/8/20 16:32
     */
    public PaasFormDataEntity transferUserTeamToFormData(IndexTypeEnum indexTypeEnum, UserTeamEntity userTeamEntity) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        AbstractUserTeamTransferSubForm transfer = (AbstractUserTeamTransferSubForm) subFormFactory.createTransfer(indexTypeEnum);
        return transfer.transferTeamToFormData(userTeamEntity);
    }

    /**
     * Description: 把数据库团队数据转化为es的格式
     * @param indexTypeEnum es索引枚举
     * @see com.xbongbong.paas.enums.IndexTypeEnum
     * @param userTeamEntities 团队实体
     * @return java.util.List<com.xbongbong.paas.domain.entity.PaasFormDataEntity>
     * @author 魏荣杰
     * @date 2020/8/20 16:32
     */
    public List<PaasFormDataEntity> transferUserTeamToFormDataList(IndexTypeEnum indexTypeEnum, List<? extends UserTeamEntity> userTeamEntities) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        AbstractUserTeamTransferSubForm transfer = (AbstractUserTeamTransferSubForm) subFormFactory.createTransfer(indexTypeEnum);
        return transfer.transferTeamToFormDataList(userTeamEntities);
    }


    /**
     * Description: 把数据库团队es数据转化为数据库的格式
     * @param indexTypeEnum es索引枚举
     * @see com.xbongbong.paas.enums.IndexTypeEnum
     * @param paasFormDataEntity 团队实体
     * @return com.xbongbong.saas.domain.entity.UserTeamEntity
     * @author 魏荣杰
     * @date 2020/8/20 16:32
     */
    public UserTeamEntity transferFormDataToUserTeam(IndexTypeEnum indexTypeEnum, PaasFormDataEntity paasFormDataEntity) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        AbstractUserTeamTransferSubForm transfer = (AbstractUserTeamTransferSubForm) subFormFactory.createTransfer(indexTypeEnum);
        return transfer.transferFormDataToTeam(paasFormDataEntity);
    }

    /**
     * Description: 把数据库团队es数据转化为数据库的格式
     * @param indexTypeEnum es索引枚举
     * @see com.xbongbong.paas.enums.IndexTypeEnum
     * @param paasFormDataEntities 团队实体
     * @return java.util.List<com.xbongbong.saas.domain.entity.UserTeamEntity>
     * @author 魏荣杰
     * @date 2020/8/20 16:32
     */
    public List<? extends UserTeamEntity> transferFormDataToUserTeamList(IndexTypeEnum indexTypeEnum, List<PaasFormDataEntity> paasFormDataEntities) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        AbstractUserTeamTransferSubForm transfer = (AbstractUserTeamTransferSubForm) subFormFactory.createTransfer(indexTypeEnum);
        return transfer.transferFormDataToTeamList(paasFormDataEntities);
    }

    /**
     * Description: 把数据库团队(特殊业务)数据转化为es的格式
     * @param indexTypeEnum es索引枚举
     * @see com.xbongbong.paas.enums.IndexTypeEnum
     * @param userAndDepTeamEntity 团队实体
     * @return com.xbongbong.paas.domain.entity.PaasFormDataEntity
     * @author 魏荣杰
     * @date 2020/8/20 16:32
     */
    public PaasFormDataEntity transferUserAndDepTeamToFormData(IndexTypeEnum indexTypeEnum, UserAndDepTeamEntity userAndDepTeamEntity) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        AbstractUserAndDepTeamTransferSubForm transfer = (AbstractUserAndDepTeamTransferSubForm) subFormFactory.createTransfer(indexTypeEnum);
        return transfer.transferTeamToFormData(userAndDepTeamEntity);
    }

    /**
     * Description: 把数据库团队(特殊业务)数据转化为es的格式
     * @param indexTypeEnum es索引枚举
     * @see com.xbongbong.paas.enums.IndexTypeEnum
     * @param userAndDepTeamEntities 团队实体
     * @return java.util.List<com.xbongbong.paas.domain.entity.PaasFormDataEntity>
     * @author 魏荣杰
     * @date 2020/8/20 16:32
     */
    public List<PaasFormDataEntity> transferUserAndDepTeamToFormDataList(IndexTypeEnum indexTypeEnum, List<? extends UserAndDepTeamEntity> userAndDepTeamEntities) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        AbstractUserAndDepTeamTransferSubForm transfer = (AbstractUserAndDepTeamTransferSubForm) subFormFactory.createTransfer(indexTypeEnum);
        return transfer.transferTeamToFormDataList(userAndDepTeamEntities);
    }

    /**
     * Description: 把数据库团队(特殊业务)es数据转化为数据库的格式
     * @param indexTypeEnum es索引枚举
     * @see com.xbongbong.paas.enums.IndexTypeEnum
     * @param paasFormDataEntity 团队实体
     * @return com.xbongbong.saas.domain.entity.UserAndDepTeamEntity
     * @author 魏荣杰
     * @date 2020/8/20 16:32
     */
    public UserAndDepTeamEntity transferFormDataToUserAndDepTeam(IndexTypeEnum indexTypeEnum, PaasFormDataEntity paasFormDataEntity) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        AbstractUserAndDepTeamTransferSubForm transfer = (AbstractUserAndDepTeamTransferSubForm) subFormFactory.createTransfer(indexTypeEnum);
        return transfer.transferFormDataToTeam(paasFormDataEntity);
    }


    /**
     * Description: 把数据库团队(特殊业务)es数据转化为数据库的格式
     * @param indexTypeEnum es索引枚举
     * @see com.xbongbong.paas.enums.IndexTypeEnum
     * @param paasFormDataEntities 团队实体
     * @return java.util.List<com.xbongbong.saas.domain.entity.UserAndDepTeamEntity>
     * @author 魏荣杰
     * @date 2020/8/20 16:32
     */
    public List<UserAndDepTeamEntity> transferFormDataToUserAndDepTeam(IndexTypeEnum indexTypeEnum, List<PaasFormDataEntity> paasFormDataEntities) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        AbstractUserAndDepTeamTransferSubForm transfer = (AbstractUserAndDepTeamTransferSubForm) subFormFactory.createTransfer(indexTypeEnum);
        return transfer.transferFormDataToTeamList(paasFormDataEntities);
    }

    /**
     * Description:
     * @param contractProductEntity
     * @return com.xbongbong.paas.domain.entity.PaasFormDataEntity
     * @throws
     * @author 魏荣杰
     * @date 2020/8/25 16:11
     * @since
     */
    public PaasFormDataEntity transferContractProductToFormData(ContractProductEntity contractProductEntity) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        ContractProductTransferSubForm transfer = (ContractProductTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_CONTRACT_PRODUCT);
        return transfer.transferEntityToFormData(contractProductEntity);
    }


    public List<? extends PaasFormDataEntity> transferContractProductToFormDataList(List<ContractProductEntity> contractProductEntities) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        ContractProductTransferSubForm transfer = (ContractProductTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_CONTRACT_PRODUCT);
        return transfer.transferEntityToFormDataList(contractProductEntities);
    }

    public ContractProductEntity transferFormDataToContractProduct(PaasFormDataEntity paasFormDataEntity) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        ContractProductTransferSubForm transfer = (ContractProductTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_CONTRACT_PRODUCT);
        return transfer.transferFormDataToEntity(paasFormDataEntity);
    }

    public List<ContractProductEntity> transferFormDataToContractProductList(List<PaasFormDataEntity> paasFormDataEntities) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        ContractProductTransferSubForm transfer = (ContractProductTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_CONTRACT_PRODUCT);
        return transfer.transferFormDataToEntityList(paasFormDataEntities);
    }


    public PaasFormDataEntity transferContractPerformanceToFormData(ContractPerformanceEntity contractPerformanceEntity) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        ContractPerformanceTransferSubForm transfer = (ContractPerformanceTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_CONTRACT_PERFORMANCE);
        return  transfer.transferEntityToFormData(contractPerformanceEntity);
    }

    public List<PaasFormDataEntity> transferContractPerformanceToFormDataList(List<ContractPerformanceEntity> contractPerformanceEntities) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        ContractPerformanceTransferSubForm transfer = (ContractPerformanceTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_CONTRACT_PERFORMANCE);
        return  transfer.transferEntityToFormDataList(contractPerformanceEntities);
    }

    public ContractPerformanceEntity transferFormDataToContractPerformance(PaasFormDataEntity paasFormDataEntity) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        ContractPerformanceTransferSubForm transfer = (ContractPerformanceTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_CONTRACT_PERFORMANCE);
        return  transfer.transferFormDataToEntity(paasFormDataEntity);
    }


    public List<ContractPerformanceEntity> transferFormDataToContractPerformanceList(List<PaasFormDataEntity> paasFormDataEntities) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        ContractPerformanceTransferSubForm transfer = (ContractPerformanceTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_CONTRACT_PERFORMANCE);
        return  transfer.transferFormDataToEntityList(paasFormDataEntities);
    }


    public PaasFormDataEntity transferProductWarehouseToFormData(ProductWarehouseEntity productWarehouseEntity) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        ProductWarehouseTransferSubForm transfer = (ProductWarehouseTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_PRODUCT_WAREHOUSE);
        return transfer.transferEntityToFormData(productWarehouseEntity);
    }

    public List<PaasFormDataEntity> transferProductWarehouseToFormDataList(List<ProductWarehouseEntity> productWarehouseEntities) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        ProductWarehouseTransferSubForm transfer = (ProductWarehouseTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_PRODUCT_WAREHOUSE);
        return transfer.transferEntityToFormDataList(productWarehouseEntities);
    }

    public ProductWarehouseEntity transferFormDataToProductWarehouse(PaasFormDataEntity paasFormDataEntity) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        ProductWarehouseTransferSubForm transfer = (ProductWarehouseTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_PRODUCT_WAREHOUSE);
        return transfer.transferFormDataToEntity(paasFormDataEntity);
    }

    public List<PaasFormDataEntity> transferDistributorAccountToFormDataList(List<DistributorAccountEntity> distributorAccountEntities) {
        DistributorAccountTransferSubForm transfer = (DistributorAccountTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_DISTRIBUTOR_ACCOUNT);
        return transfer.transferEntityToFormDataList(distributorAccountEntities);
    }

    public List<ProductWarehouseEntity> transferFormDataToProductWarehouseList(List<PaasFormDataEntity> paasFormDataEntities) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        ProductWarehouseTransferSubForm transfer = (ProductWarehouseTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_PRODUCT_WAREHOUSE);
        return transfer.transferFormDataToEntityList(paasFormDataEntities);
    }


    public PaasFormDataEntity transferProductStockToFormData(ProductStockEntity productStockEntity) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        ProductStockTransferSubForm transfer = (ProductStockTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_PRODUCT_STOCK_INFO);
        return transfer.transferEntityToFormData(productStockEntity);
    }

    public List<PaasFormDataEntity> transferProductStockToFormDataList(List<ProductStockEntity> productStockEntities) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        ProductStockTransferSubForm transfer = (ProductStockTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_PRODUCT_STOCK_INFO);
        return transfer.transferEntityToFormDataList(productStockEntities);
    }

    public ProductStockEntity transferFormDataToProductStock(PaasFormDataEntity paasFormDataEntity) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        ProductStockTransferSubForm transfer = (ProductStockTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_PRODUCT_STOCK_INFO);
        return transfer.transferFormDataToEntity(paasFormDataEntity);
    }


    public List<ProductStockEntity> transferFormDataToProductStockList(List<PaasFormDataEntity> paasFormDataEntities) {
//        SubFormFactory subFormFactory = new SubFormFactory();
        ProductStockTransferSubForm transfer = (ProductStockTransferSubForm) subFormFactory.createTransfer(IndexTypeEnum.IDX_SAAS_PRODUCT_STOCK_INFO);
        return transfer.transferFormDataToEntityList(paasFormDataEntities);
    }
}


